package com.gxa.insurance.service.impl;

import com.gxa.insurance.exception.BusinessException;
import com.gxa.insurance.exception.ExceptionCode;
import com.gxa.insurance.mapper.RoleMapper;
import com.gxa.insurance.pojo.Role;
import com.gxa.insurance.service.RoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author wang li sha
 * @date 2022-06-06 16:33
 */
@Service("RoleService")
@Transactional(rollbackFor = Throwable.class)
public class RoleServiceImpl implements RoleService {
    @Autowired
    RoleMapper roleMapper;

    @Override
    public List<Role> selectAll() throws Exception {
        List<Role> roles = roleMapper.selectAll();
        if (roles.size() == 0) {
            throw new BusinessException(ExceptionCode.ROLE_IS_EMPTY);
        }
        return roles;
    }


}
